﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Master.Master" CodeBehind="FIM_Payroll.aspx.cs" Inherits="KPIS.GERP.GFMS.APP.App_UI.Forms.FIM_Payroll" EnableEventValidation="false" %>

<%@ Register Src="../UserControls/DatePicker.ascx" TagName="DatePicker" TagPrefix="uc1" %>

<asp:Content runat="server" ContentPlaceHolderID="head">
    <title>เตรียมข้อมูลการจ่ายเงินเดือน</title>
    <link href="../CssClass.css" rel="stylesheet" type="text/css" />
    <script language="JavaScript" src="../Scripts/Common.js" type="text/jscript"></script>
    <script language="JavaScript" src="../Scripts/DatePicker.js" type="text/jscript"></script>
    <style type="text/css">
        .formCaption {
            float: left;
            font-weight: bold;
            font-size: 12px;
            width: 200px;
            text-align: right;
            margin-right: 15px;
        }

        .auto-style1 {
            width: 575px;
        }

        .auto-style2 {
            width: 4835px;
        }
    </style>
</asp:Content>

<asp:Content runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script src="<%= Page.ResolveUrl("~/js/jquery-1.9.1.js") %>" type="text/javascript"></script>
        <script type="text/javascript">


            var bodyOverflow, htmlOverflow; function closeHandler(sender, args) { document.body.style.overflow = bodyOverflow; document.documentElement.style.overflow = htmlOverflow; sender.remove_close(closeHandler); }
            function OpenPopUpHideParentScrollBar(url, radwindowId) { bodyOverflow = document.body.style.overflow; htmlOverflow = document.documentElement.style.overflow; document.body.style.overflow = "hidden"; document.documentElement.style.overflow = "hidden"; var oWnd = radopen(url, radwindowId); oWnd.add_close(closeHandler); return oWnd; }

            function openImportPayrollClick() {
                try {

                    var oWnd = OpenPopUpHideParentScrollBar("FIM_PayrollImporterUpload.aspx", "RadWindow1");
                    oWnd.set_width(460);
                    oWnd.set_height(300);
                } catch (exception) {
                    alert(exception);
                }
            }

            function openReqReport() {
                var month = $find("<%= ddlMonth.ClientID %>")._value;
                var year = document.getElementById("<%= txbYearNo.ClientID%>").value;

                if (month == undefined || year == undefined) {
                    alert('month:' + month + 'year:' + year);
                    return;
                }

                window.open(String.format("PopupPrintExcel.aspx?Type=Salary&Month={0}&Year={1}", month, year));
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="PanelAll">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelAll" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadWindowManager runat="server" ID="RadWindowManager1" Skin="Vista">
        <Windows>
            <telerik:RadWindow Title="นำเข้าข้อมูลเงินเดือน" ID="RadWindow1" runat="server" ReloadOnShow="true" Behaviors="None" Width="500px">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
    <asp:Panel runat="server" ID="PanelAll">
        <div class="DivControl" style="height: 25px; padding-left: 25px;">

            <telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" Width="100%" SelectedIndex="0">
                <Tabs>
                    <telerik:RadTab Text="จัดเตรียมข้อมูลเงินเดือน" ToolTip="จัดเตรียมข้อมูลเงินเดือน" Height="25px" Selected="True">
                    </telerik:RadTab>
                    <telerik:RadTab Text="สรุปรายการเงินเดือนที่ต้องส่ง" ToolTip="สรุปรายการเงินเดือนที่ต้องส่ง" Height="25px">
                    </telerik:RadTab>
                </Tabs>
            </telerik:RadTabStrip>

        </div>
        <telerik:RadMultiPage runat="server" ID="RadMultiPage1" SelectedIndex="0">
            <telerik:RadPageView runat="server" ID="RadPageView1">
                <asp:Panel runat="server" ID="PanelCommand">
                    <div class="DivControl" style="height: 25px">
                        <table cellpadding="0" cellspacing="0" width="100%">
                            <tr>
                                <td>
                                    <asp:LinkButton ID="cmdViewAll" runat="server" CssClass="controlButton" OnClick="cmdViewAll_Click">
                                        <img alt="" id="imgViewAll" runat="server" src="~/App_UI/Images/Buttons/Cancel.gif" />
                                        ยกเลิกการแก้ไข
                                    </asp:LinkButton>
                                    <asp:LinkButton ID="cmdViewAll2" runat="server" CssClass="controlButton" OnClick="cmdViewAll_Click">
                                        <img alt="" id="imgViewAll2" runat="server" src="~/App_UI/Images/Buttons/Back.png" style="width: 16px; height: 16px" />
                                        กลับไปหน้ารวม
                                    </asp:LinkButton>
                                    <asp:LinkButton ID="cmdAddNew" runat="server" CssClass="controlButton" OnClick="cmdAddNew_Click">
                                        <img alt="" id="imgAddNew" runat="server" src="~/App_UI/Images/Buttons/AddRecord.gif" />
                                        เพิ่มข้อมูลใหม่
                                    </asp:LinkButton>
                                    <asp:LinkButton ID="cmdInsert" runat="server" CssClass="controlButton" OnClick="cmdInsert_Click">
                                        <img alt="" id="imgInsert" runat="server" src="~/App_UI/Images/Buttons/saveDisk.gif" />
                                        บันทึกข้อมูล
                                    </asp:LinkButton>
                                    <asp:LinkButton ID="cmdUpdate" runat="server" CssClass="controlButton" OnClick="cmdUpdate_Click">
                                        <img alt="" id="imgUpdate" runat="server" src="~/App_UI/Images/Buttons/saveDisk.gif" />
                                        บันทึกข้อมูล
                                    </asp:LinkButton>
                                    <span class="controlButton" style="cursor: pointer; border: none;" onclick="openImportPayrollClick()">
                                        <asp:Image ID="Image2" ImageUrl="~/App_UI/Images/Buttons/Movedown.gif" runat="server" Width="13px" Height="13px" />
                                        นำเข้าไฟล์ Excel เงินเดือน
                                    </span><a class="controlButton" style="cursor: pointer; border: none;" href="FIM_PayrollImporter.aspx">ไฟล์เงินเดือนเก่า
                                    </a></td>
                            </tr>
                            <tr>
                                <td style="text-align: right;">
                                    <asp:Label ID="lblCurrentSalaryMonthStatus" runat="server" ForeColor="#FFC3E2FF"
                                        Style="text-shadow: 1px 1px #383838;" Font-Size="14px" Font-Bold="true">
                                        <asp:Image ID="Image1" ImageUrl="~/App_UI/Images/Buttons/Update.gif" runat="server" />
                                        เตรียมข้อมูลการจ่ายเงินเดือนนี้ไปแล้ว
                                    </asp:Label>
                                    &nbsp;
                                </td>
                            </tr>
                        </table>
                    </div>
                </asp:Panel>
                <asp:Panel ID="PanelIndex" runat="server" Width="1000px">
                    <div class="DivInfo">
                        <table width="100%">
                            <tr style="height: 36px;">
                                <td>&nbsp;&nbsp;
                            <span style="font-weight: bold; font-size: 14px;">จัดเตรียมข้อมูลการจ่ายเงินเดือน</span> </td>
                                <td width="130px">&nbsp;</td>
                                <td align="right" width="100px">สำหรับเดือน :
                                </td>
                                <td width="100px">
                                    <telerik:RadComboBox ID="ddlMonth" OnSelectedIndexChanged="txbYearNo_TextChanged" runat="server" AutoPostBack="true" Filter="Contains" Width="100px">
                                        <Items>
                                            <telerik:RadComboBoxItem Text="มกราคม" Value="1" />
                                            <telerik:RadComboBoxItem Text="กุมภาพันธ์" Value="2" />
                                            <telerik:RadComboBoxItem Text="มีนาคม" Value="3" />
                                            <telerik:RadComboBoxItem Text="เมษายน" Value="4" />
                                            <telerik:RadComboBoxItem Text="พฤษภาคม" Value="5" />
                                            <telerik:RadComboBoxItem Text="มิถุนายน" Value="6" />
                                            <telerik:RadComboBoxItem Text="กรกฎาคม" Value="7" />
                                            <telerik:RadComboBoxItem Text="สิงหาคม" Value="8" />
                                            <telerik:RadComboBoxItem Text="กันยายน" Value="9" />
                                            <telerik:RadComboBoxItem Text="ตุลาคม" Value="10" />
                                            <telerik:RadComboBoxItem Text="พฤศจิกายน" Value="11" />
                                            <telerik:RadComboBoxItem Text="ธันวาคม" Value="12" />
                                        </Items>
                                    </telerik:RadComboBox>
                                </td>
                                <td align="right" width="20px">ปี:
                                </td>
                                <td width="120px">
                                    <telerik:RadNumericTextBox ID="txbYearNo" runat="server"
                                        Width="100px" ShowSpinButtons="True" AutoPostBack="true"
                                        NumberFormat-DecimalDigits="0" NumberFormat-GroupSeparator=""
                                        OnTextChanged="txbYearNo_TextChanged" />
                                </td>
                                <td width="150px">
                                    <asp:Button runat="server" ID="btnSentPayment" Text="ส่งทำเรื่องขอเบิก" OnClick="btnSentPayment_Click" />
                                    <asp:Button runat="server" ID="btnUndoSentPayment" Text="*ยกเลิกส่งเบิก(ทดสอบ)" OnClick="btnUndoSentPayment_Click" BackColor="Red" />
                                </td>
                            </tr>
                        </table>
                    </div>
                    <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="RadGridIndex" runat="server"
                        AutoGenerateColumns="False" ShowStatusBar="True" AllowPaging="True" AllowSorting="True"
                        AllowFilteringByColumn="True" Width="998px" AllowRowSelect="true"
                        GroupingSettings-GroupByFieldsSeparator="&nbsp;&nbsp;&nbsp;&nbsp;"
                        GroupingSettings-GroupContinuedFormatString=""
                        GroupingSettings-GroupContinuesFormatString=""
                        GroupingSettings-GroupSplitFormat=""
                        CellSpacing="0" GridLines="None" Skin="Simple" OnNeedDataSource="RadGridIndex_NeedDataSource" PageSize="30">
                        <MasterTableView AllowMultiColumnSorting="True" CellSpacing="-1" Width="100%"
                            CommandItemDisplay="Top" CommandItemSettings-ShowRefreshButton="true" CommandItemSettings-ShowAddNewRecordButton="false"
                            DataKeyNames="payroll_seq" NoMasterRecordsText="< ไม่มีข้อมูล >">
                            <CommandItemSettings ExportToPdfText="Export to PDF" />
                            <RowIndicatorColumn>
                                <HeaderStyle Width="20px" />
                            </RowIndicatorColumn>
                            <ExpandCollapseColumn>
                                <HeaderStyle Width="20px" />
                            </ExpandCollapseColumn>
                            <Columns>
                                <telerik:GridTemplateColumn InitializeTemplatesFirst="false" AllowFiltering="False">
                                    <HeaderStyle Width="30px"></HeaderStyle>
                                    <ItemTemplate>
                                        <div>
                                            <asp:LinkButton ID="cmdDetail" runat="server" CssClass="controlButton" OnCommand="cmdDetail_OnCommand"
                                                CommandArgument='<%# Eval("payroll_seq")  %>' ToolTip="รายละเอียดข้อมูล" BorderStyle="none" Style="padding: 0;">
                                                <img alt="" id="imgDetail" runat="server" src="~/App_UI/Images/Buttons/Magnifier.gif" />
                                            </asp:LinkButton>
                                        </div>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn DataField="payroll_seq" HeaderText="PK"
                                    UniqueName="payroll_seq" AutoPostBackOnFilter="True" Visible="False">
                                    <HeaderStyle HorizontalAlign="Center" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="ref_no" HeaderText="เลขที่อ้างอิง"
                                    UniqueName="ref_no" AutoPostBackOnFilter="True" CurrentFilterFunction="Contains"
                                    DataFormatString="{0:n}" FilterControlAltText="Filter con_name column"
                                    FilterControlWidth="100%" AllowFiltering="True" AllowSorting="True">
                                    <HeaderStyle HorizontalAlign="Center" Width="90px" />
                                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="title" HeaderText="ใช้ค่าใช้จ่ายโครงการ"
                                    UniqueName="title" AutoPostBackOnFilter="True" CurrentFilterFunction="Contains"
                                    FilterControlAltText="Filter title column" FilterControlWidth="100%" ShowFilterIcon="False">
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Left" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="IcmMasContact.NameTh" HeaderText="จ่ายให้กับ"
                                    UniqueName="con_name" AutoPostBackOnFilter="True" CurrentFilterFunction="Contains"
                                    DataFormatString="{0:n}" FilterControlAltText="Filter con_name column"
                                    FilterControlWidth="100%" ShowFilterIcon="False">
                                    <HeaderStyle Width="170px" HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn AutoPostBackOnFilter="True" CurrentFilterFunction="Contains"
                                    DataField="mas_source_name" FilterControlAltText="Filter mas_source_name column"
                                    FilterControlWidth="100%" HeaderText="แหล่งเงิน" ShowFilterIcon="False" UniqueName="mas_source_name">
                                    <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="amount" HeaderText="จำนวนสุทธิ" AllowFiltering="False"
                                    UniqueName="amount" DataFormatString="{0:n} บาท" ShowFilterIcon="False" DataType="System.Decimal">
                                    <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Right" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="deduction_total_amount" HeaderText="เงินหัก" AllowFiltering="False"
                                    UniqueName="deduction_total_amount" DataFormatString="{0:n} บาท" ShowFilterIcon="False"
                                    DataType="System.Decimal">
                                    <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Right" />
                                </telerik:GridBoundColumn>
                                <telerik:GridTemplateColumn InitializeTemplatesFirst="false" AllowFiltering="False">
                                    <HeaderStyle Width="30px"></HeaderStyle>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="cmdEdit" runat="server" CssClass="controlButton" BorderStyle="none"
                                            ToolTip="แก้ไขข้อมูล" OnCommand="cmdEdit_OnCommand" Visible='<%#AllowEditData%>' Style="padding: 0;"
                                            CommandArgument='<%# Eval("payroll_seq")  %>'>
                                            <img alt="" id="imgEdit" runat="server" src="~/App_UI/Images/Buttons/Edit.gif" />
                                        </asp:LinkButton>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn InitializeTemplatesFirst="false" AllowFiltering="False">
                                    <HeaderStyle Width="30px"></HeaderStyle>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="cmdDelete" runat="server" CssClass="controlButton" Visible='<%#AllowEditData%>'
                                            OnClientClick="javascript: return confirm('ต้องการลบรายการนี้หรือไม่?');" Style="padding: 0;"
                                            OnCommand="cmdDelete_OnCommand" ToolTip="ลบรายการที่เลือก" BorderStyle="none"
                                            CommandArgument='<%# Eval("payroll_seq")  %>'>
                                            <img alt="" id="imgDelete" runat="server" src="~/App_UI/Images/Buttons/Delete.gif" />
                                        </asp:LinkButton>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                </telerik:GridTemplateColumn>
                            </Columns>
                            <EditFormSettings>
                                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                </EditColumn>
                            </EditFormSettings>
                            <PagerStyle Mode="NumericPages" AlwaysVisible="true"
                                FirstPageToolTip="กลับหน้าแรก" LastPageToolTip="ไปหน้าสุดท้าย"
                                NextPagesToolTip="หน้าถัดไป" NextPageToolTip="หน้าถัดไป"
                                PrevPagesToolTip="ย้อนกลับ" PrevPageToolTip="ย้อนกลับ" />
                        </MasterTableView>
                        <GroupingSettings GroupByFieldsSeparator="&nbsp;&nbsp;&nbsp;&nbsp;"
                            GroupContinuedFormatString="" GroupContinuesFormatString=""
                            GroupSplitFormat="" />
                        <ClientSettings EnableRowHoverStyle="True" EnablePostBackOnRowClick="false">
                            <Selecting AllowRowSelect="True" />
                            <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                        </ClientSettings>
                        <FilterMenu EnableImageSprites="False">
                        </FilterMenu>
                    </telerik:RadGrid>
                    <table>
                        <tr>
                            <td>
                                จำนวนคนที่รับเงินเดือน
                            </td>
                            <td>
                                <asp:Label ID="lblCountEmp" runat="server">
                                </asp:Label>
                            </td>
                            <td>
                                คน
                            </td>
                        </tr>
                    </table>

                </asp:Panel>
                <asp:Panel ID="PanelEdit" runat="server" Visible="false">
                    <div class="DivInfo">
                        <table width="100%">
                            <tr>
                                <td><span style="font-weight: bold;">ข้อมูลค่าใช้จ่ายเงินได้
                                    <asp:HiddenField ID="hdfPayRollSeq" runat="server" />
                                </span></td>
                            </tr>
                        </table>
                    </div>
                    <ul class="formList" style="width: 910px; margin-top: 10px;">
                        <li>
                            <div class="formCaption">
                                เลขที่อ้างอิง 
                            </div>
                            <asp:Label runat="server" ID="lblRefNo" ForeColor="#FFE4D735" />
                            &nbsp;
                        </li>
                        <li>
                            <div class="formCaption">
                                สำหรับ 
                            </div>
                            <asp:Label runat="server" ID="lblMonthYear" ForeColor="Blue" />
                            <asp:HiddenField ID="hdfYearNo" runat="server" />
                            <asp:HiddenField ID="hdfMonthNo" runat="server" />
                            &nbsp;
                        </li>
                        <li>
                            <div class="formCaption">
                                โดยใช้ปีงบประมาณ 
                            </div>
                            <telerik:RadNumericTextBox ID="txbBgmYearNo" runat="server"
                                Width="100px" ShowSpinButtons="True" AutoPostBack="true"
                                NumberFormat-DecimalDigits="0" NumberFormat-GroupSeparator=""
                                OnTextChanged="txbBgmYearNo_TextChanged" />
                            &nbsp;
                            <asp:Label ID="lblBgmYearNo" runat="server" ForeColor="Blue"></asp:Label>
                            <span style="color: red">*</span> </li>
                        <li>
                            <div class="formCaption">
                                ประเภทบุคลากร 
                            </div>
                            <telerik:RadComboBox ID="ddlEmpTypeSeq" runat="server" AutoPostBack="true" DataTextField="emp_type_name"
                                DataValueField="emp_type_seq" Filter="Contains" OnSelectedIndexChanged="ddlEmpTypeSeq_SelectedIndexChanged">
                            </telerik:RadComboBox>
                            <asp:Label ID="lblEmpTypeSeq" runat="server" ForeColor="Blue"></asp:Label>
                            <span style="color: red">*</span> </li>
                        <li>
                            <table width="100%">
                                <tr>
                                    <td width="200px">
                                        <div class="formCaption" style="left: 0px;">
                                            วันที่ต้องการใช้
                                        </div>
                                    </td>
                                    <td width="120px">
                                        <uc1:DatePicker ID="dtpReqDate" runat="server" />
                                        <asp:Label ID="lblReqDate" runat="server" ForeColor="Blue"></asp:Label>
                                    </td>
                                    <td width="10px"><span style="color: red">*</span> </td>
                                    <td></td>
                                </tr>
                            </table>
                        </li>
                        <li>
                            <div class="formCaption">
                                แหล่งเงิน
                            </div>
                            <telerik:RadComboBox ID="ddlBgmSourceSeq" runat="server"
                                DataTextField="bgm_source_name" DataValueField="bgm_source_seq"
                                Filter="Contains" AutoPostBack="true"
                                OnSelectedIndexChanged="ddlBgmSourceSeq_SelectedIndexChanged">
                            </telerik:RadComboBox>
                            <asp:Label ID="lblBgmSourceSeq" runat="server" ForeColor="Blue"></asp:Label>
                            <span style="color: red">*</span> </li>
                        <li>
                            <div class="formCaption">
                                หมวดค่าใช้จ่าย
                            </div>
                            <telerik:RadComboBox ID="ddlExpGrpSeq" runat="server" OnSelectedIndexChanged="ddlExpGrpSeq_SelectedIndexChanged"
                                DataTextField="BGM_EXP_GRP_NAME" DataValueField="BGM_EXP_GRP_SEQ"
                                Filter="Contains" AutoPostBack="true">
                            </telerik:RadComboBox>
                            <asp:Label ID="lblExpGrpSeq" runat="server" ForeColor="Blue"></asp:Label>
                            <span style="color: red">*</span> </li>
                        <li>
                            <div class="formCaption">
                                อนุมัติโครงการ
                            </div>
                            <telerik:RadComboBox ID="ddlBgmProjOperSeq" runat="server" AutoPostBack="true"
                                DataTextField="bgm_proj_oper_name" DataValueField="bgm_proj_oper_seq"
                                Filter="Contains" OnSelectedIndexChanged="ddlBgmProjOperSeq_SelectedIndexChanged" Width="550px">
                            </telerik:RadComboBox>
                            <asp:Label ID="lblBgmProjOperSeq" runat="server" ForeColor="Blue"></asp:Label>
                            <span style="color: red">*</span> </li>
                        <li>
                            <div class="formCaption">
                                ค่าใช้จ่าย
                            </div>
                            <telerik:RadComboBox ID="ddlBgmProjOperExpSeq" runat="server" AutoPostBack="true"
                                DataTextField="name"
                                DataValueField="bgm_proj_oper_exp_seq"
                                Filter="Contains" OnSelectedIndexChanged="ddlBgmProjOperExpSeq_SelectedIndexChanged" Width="550px">
                            </telerik:RadComboBox>
                            <asp:Label ID="lblBgmProjOperExpSeq" runat="server" ForeColor="Blue"></asp:Label>
                            <span style="color: red">*</span> </li>
                        <li>
                            <div class="formCaption">
                                ชื่อรายการค่าใช้จ่าย 
                            </div>
                            <asp:TextBox ID="txbTitle" runat="server" Width="550px" Height="51px" TextMode="MultiLine" />
                            <asp:Label ID="lblTitle" runat="server" ForeColor="Blue" Font-Bold="True"></asp:Label>
                            <span style="color: red">*</span> </li>
                        <li>
                            <div class="formCaption">
                                จ่ายให้กับ
                            </div>
                            <telerik:RadComboBox ID="ddlConId" runat="server" AutoPostBack="false"
                                DataTextField="NameTh" DataValueField="ConId" Filter="Contains" Width="550px">
                            </telerik:RadComboBox>
                            <asp:Label ID="lblConId" runat="server" ForeColor="Blue"></asp:Label>
                            <span style="color: red">*</span> </li>
                        <li>
                            <div class="formCaption">
                                ยอดเงินสุทธิ (บาท) 
                            </div>
                            <telerik:RadNumericTextBox ID="txbAmount" runat="server" NumberFormat="#,##0.00"
                                Value="0" MinValue="0" />
                            <asp:Label runat="server" ID="lblAmount" ForeColor="Blue"></asp:Label>
                            <span style="color: red">*</span> </li>
                    </ul>
                    <br />
                    <hr />
                    <br />
                    <br />
                    <br />
                </asp:Panel>
                <asp:Panel runat="server" ID="PanelDeductionCommand">
                    <div class="DivControl">
                        <table cellpadding="0" cellspacing="0" width="100%">
                            <tr>
                                <td>
                                    <asp:LinkButton ID="cmdViewAllDeduction1" runat="server" CssClass="controlButton" OnClick="cmdViewAllDeduction_Click">
                                        <img alt="" id="img1" runat="server" src="~/App_UI/Images/Buttons/Cancel.gif" />
                                        ยกเลิกการแก้ไขรายการเงินหัก
                                    </asp:LinkButton>
                                    <asp:LinkButton ID="cmdViewAllDeduction2" runat="server" CssClass="controlButton" OnClick="cmdViewAllDeduction_Click">
                                        <img alt="" id="img2" runat="server" src="~/App_UI/Images/Buttons/Back.png" style="width: 16px; height: 16px" />
                                        กลับไปหน้ารายระเอียดค่าใช้จ่ายเงินได้
                                    </asp:LinkButton>
                                    <asp:LinkButton ID="cmdAddNewDeduction" runat="server" CssClass="controlButton" OnClick="cmdAddNewDeduction_Click">
                                        <img alt="" id="img3" runat="server" src="~/App_UI/Images/Buttons/AddRecord.gif" />
                                        เพิ่มข้อมูลเงินหักใหม่
                                    </asp:LinkButton>
                                    <asp:LinkButton ID="cmdInsertDeduction" runat="server" CssClass="controlButton" OnClick="cmdInsertDeduction_Click">
                                        <img alt="" id="img4" runat="server" src="~/App_UI/Images/Buttons/saveDisk.gif" />
                                        บันทึกข้อมูล
                                    </asp:LinkButton>
                                    <asp:LinkButton ID="cmdUpdateDeduction" runat="server" CssClass="controlButton" OnClick="cmdUpdateDeduction_Click">
                                        <img alt="" id="img5" runat="server" src="~/App_UI/Images/Buttons/saveDisk.gif" />
                                        บันทึกข้อมูล
                                    </asp:LinkButton>
                                </td>
                            </tr>
                        </table>
                    </div>
                </asp:Panel>
                <asp:Panel ID="PanelDeductionIndex" runat="server" Visible="false">
                    <div class="DivInfo" style="width: 100%; text-align: left;">
                        <table width="100%">
                            <tr>
                                <td><span style="font-weight: bold;">ข้อมูลค่าใช้จ่ายเงินหักภายใต้รายการ "<asp:Label runat="server" ID="lblPayrollTitle2" ForeColor="Blue"></asp:Label>
                                    "
                                </span></td>
                                <td width="200px" style="text-align: right; padding-right: 25px;"><span style="font-weight: bold; color: blue">รวม
                                    <asp:Label runat="server" ID="lblDeductionTotalAmount"></asp:Label>
                                </span></td>
                            </tr>
                        </table>
                    </div>

                    <div>
                        <telerik:RadGrid ID="RadGridDeductionIndex" runat="server"
                            AutoGenerateColumns="False" ShowStatusBar="True" AllowPaging="True" AllowSorting="True" CellSpacing="0" GridLines="None" Skin="Simple"
                            OnItemCommand="RadGridDeductionIndex_ItemCommand">
                            <MasterTableView AllowMultiColumnSorting="True" CellSpacing="-1" Width="100%"
                                CommandItemDisplay="Top" CommandItemSettings-ShowRefreshButton="true" CommandItemSettings-ShowAddNewRecordButton="false"
                                DataKeyNames="payroll_seq" NoMasterRecordsText="< ไม่มีข้อมูล >">
                                <CommandItemSettings ExportToPdfText="Export to PDF" />
                                <RowIndicatorColumn>
                                    <HeaderStyle Width="20px" />
                                </RowIndicatorColumn>
                                <ExpandCollapseColumn>
                                    <HeaderStyle Width="20px" />
                                </ExpandCollapseColumn>
                                <Columns>
                                    <telerik:GridTemplateColumn InitializeTemplatesFirst="false" AllowFiltering="False">
                                        <HeaderStyle Width="30px"></HeaderStyle>
                                        <ItemTemplate>
                                            <asp:LinkButton ID="cmdDetail" runat="server" CssClass="controlButton" OnCommand="cmdDetailDeduction_OnCommand"
                                                CommandArgument='<%# Eval("payroll_deduction_seq")  %>' ToolTip="รายละเอียดข้อมูล" BorderStyle="none"
                                                Style="padding: 0;">
                                                <img alt="" id="imgDetail" runat="server" src="~/App_UI/Images/Buttons/Magnifier.gif" />
                                            </asp:LinkButton>
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridBoundColumn DataField="payroll_deduction_seq" HeaderText="เลขที่อ้างอิง"
                                        UniqueName="payroll_deduction_seq" AutoPostBackOnFilter="True" Visible="False"
                                        FilterControlAltText="Filter payroll_deduction_seq column">
                                        <HeaderStyle HorizontalAlign="Center" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="title" HeaderText="รายการเงินหัก"
                                        UniqueName="title" AutoPostBackOnFilter="True" CurrentFilterFunction="Contains"
                                        FilterControlAltText="Filter title column" FilterControlWidth="100%" ShowFilterIcon="False">
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Left" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="IcmMasContact.NameTh" HeaderText="จ่ายให้กับ"
                                        UniqueName="con_name" AutoPostBackOnFilter="True" CurrentFilterFunction="Contains"
                                        DataFormatString="{0:n}" FilterControlAltText="Filter con_name column"
                                        FilterControlWidth="100%" ShowFilterIcon="False">
                                        <HeaderStyle Width="170px" HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Center" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="amount" HeaderText="จำนวนสุทธิ"
                                        UniqueName="amount" AutoPostBackOnFilter="True" CurrentFilterFunction="Contains"
                                        DataFormatString="{0:n} บาท" FilterControlAltText="Filter amount column"
                                        FilterControlWidth="100%" ShowFilterIcon="False" DataType="System.Decimal">
                                        <HeaderStyle Width="120px" HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Right" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridTemplateColumn InitializeTemplatesFirst="false" AllowFiltering="False">
                                        <HeaderStyle Width="30px"></HeaderStyle>
                                        <ItemTemplate>
                                            <asp:LinkButton ID="cmdEdit" runat="server" CssClass="controlButton" BorderStyle="none"
                                                ToolTip="แก้ไขข้อมูล" OnCommand="cmdEditDeduction_OnCommand" Visible='<%#AllowEditData%>'
                                                CommandArgument='<%# Eval("payroll_deduction_seq")  %>' Style="padding: 0;">
                                                <img alt="" id="imgEdit" runat="server" src="~/App_UI/Images/Buttons/Edit.gif" />
                                            </asp:LinkButton>
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn InitializeTemplatesFirst="false" AllowFiltering="False">
                                        <HeaderStyle Width="30px"></HeaderStyle>
                                        <ItemTemplate>
                                            <asp:LinkButton ID="cmdDelete" runat="server" CssClass="controlButton"
                                                OnClientClick="javascript: return confirm('ต้องการลบรายการนี้หรือไม่?');" Visible='<%#AllowEditData%>'
                                                OnCommand="cmdDeleteDeduction_OnCommand" ToolTip="ลบรายการที่เลือก" BorderStyle="none"
                                                CommandArgument='<%# Eval("payroll_deduction_seq")  %>' Style="padding: 0;">
                                                <img alt="" id="imgDelete" runat="server" src="~/App_UI/Images/Buttons/Delete.gif" />
                                            </asp:LinkButton>
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                    </telerik:GridTemplateColumn>
                                </Columns>
                                <EditFormSettings>
                                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                    </EditColumn>
                                </EditFormSettings>
                                <PagerStyle Mode="NumericPages" AlwaysVisible="true"
                                    FirstPageToolTip="กลับหน้าแรก" LastPageToolTip="ไปหน้าสุดท้าย"
                                    NextPagesToolTip="หน้าถัดไป" NextPageToolTip="หน้าถัดไป"
                                    PrevPagesToolTip="ย้อนกลับ" PrevPageToolTip="ย้อนกลับ" />
                            </MasterTableView>
                            <GroupingSettings GroupByFieldsSeparator="&nbsp;&nbsp;&nbsp;&nbsp;"
                                GroupContinuedFormatString="" GroupContinuesFormatString=""
                                GroupSplitFormat="" />
                            <ClientSettings EnableRowHoverStyle="True" EnablePostBackOnRowClick="false">
                                <Selecting AllowRowSelect="True" />
                                <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                            </ClientSettings>
                            <FilterMenu EnableImageSprites="False">
                            </FilterMenu>
                        </telerik:RadGrid>
                    </div>
                </asp:Panel>
                <asp:Panel ID="PanelDeductionEdit" runat="server" Width="1000px">
                    <div class="DivInfo">
                        <table width="100%">
                            <tr>
                                <td><b>ข้อมูลค่าใช้จ่ายเงินหักภายใต้รายการ "<asp:Label runat="server" ID="lblPayrollTitle3"></asp:Label>
                                    "</b>
                                    <asp:HiddenField runat="server" ID="hdfPayRollDeductionSeq" />
                                </td>
                            </tr>
                        </table>
                    </div>
                    <ul class="formList" style="width: 910px; margin-top: 10px;">
                        <li>
                            <div class="formCaption">
                                ชื่อรายการเงินหัก
                            </div>
                            <asp:TextBox ID="txbTitleDeduction" runat="server" Width="550px" Height="51px" TextMode="MultiLine" />
                            <asp:Label ID="lblTitleDeduction" runat="server" ForeColor="Blue"></asp:Label>
                            <span style="color: red">*</span> </li>
                        <li>
                            <div class="formCaption">
                                จ่ายให้กับ
                            </div>
                            <telerik:RadComboBox ID="ddlConIdDeduction" runat="server" AutoPostBack="false"
                                DataTextField="NameTh" DataValueField="ConId" Filter="Contains" Width="550px">
                            </telerik:RadComboBox>
                            <asp:Label ID="lblConIdDeduction" runat="server" ForeColor="Blue"></asp:Label>
                            <span style="color: red">*</span> </li>
                        <li>
                            <div class="formCaption">
                                ยอดเงินสุทธิ (บาท) 
                            </div>
                            <telerik:RadNumericTextBox ID="txbAmountDeduction" runat="server" NumberFormat="#,##0.00"
                                Value="0" MinValue="0" />
                            <asp:Label runat="server" ID="lblAmountDeduction" ForeColor="Blue"></asp:Label>
                            <span style="color: red">*</span> </li>
                    </ul>
                </asp:Panel>
                <br />
                <br />
                <br />
            </telerik:RadPageView>
            <telerik:RadPageView runat="server" ID="RadPageView2">
                <asp:Panel ID="PanelPayrollTotal" runat="server" Width="1000px">
                    <div class="DivInfo">
                        <asp:Label Font-Size="Medium" Font-Bold="true" ID="Label1" runat="server" Text="ยอดเงินคงเหลือทั้งหมด = ">
                            <asp:Label Font-Size="Medium" Font-Bold="true" ID="lblTotalAmount" runat="server"></asp:Label>
                        </asp:Label>
                        <br />
                        <br />

                        <table align="center">
                            <tr>
                                <td style="font-size: medium; padding: 3px" class="auto-style1" colspan="2">
                                    <b>รายการที่ต้องจ่ายเงินทั้งหมด</b>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <telerik:RadGrid ID="RadGridPayrollTotal" runat="server" AllowAutomaticDeletes="True"
                                        AllowFilteringByColumn="false" AllowMultiRowEdit="True"
                                        AutoGenerateColumns="False" AllowSorting="True" AllowMultiRowSelection="false"
                                        AllowPaging="True"
                                        EnableAJAX="True" EnableAJAXLoadingTemplate="True"
                                        GridLines="None" Width="450px" AllowRowSelect="true"
                                        OnItemCommand="RadGridPayrollTotal_ItemCommand">

                                        <MasterTableView AllowMultiColumnSorting="True" CellSpacing="-1" Width="100%"
                                            CommandItemDisplay="Top" CommandItemSettings-ShowRefreshButton="true" CommandItemSettings-ShowAddNewRecordButton="false"
                                            DataKeyNames="ConId" NoMasterRecordsText="< ไม่มีข้อมูล >">
                                            <Columns>
                                                <telerik:GridClientSelectColumn UniqueName="checkCol">
                                                    <HeaderStyle Width="10px" />
                                                </telerik:GridClientSelectColumn>
                                                <telerik:GridBoundColumn DataField="DeductionTitle" HeaderText="รายการที่ต้องการออกเช็ค"
                                                    UniqueName="DeductionTitle" AutoPostBackOnFilter="True" CurrentFilterFunction="Contains"
                                                    ShowFilterIcon="False">
                                                    <HeaderStyle HorizontalAlign="Center" />
                                                    <ItemStyle HorizontalAlign="Left" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="ConId" DataField="ConId" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="payroll_seq" DataField="payroll_seq" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="payroll_deduction_seq" DataField="payroll_deduction_seq" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="pay_seq" DataField="pay_seq" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="bgm_source_seq" DataField="bgm_source_seq" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="bgm_source_seq" DataField="bgm_source_seq" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="Name" HeaderText="จ่ายให้กับ"
                                                    UniqueName="Name" AutoPostBackOnFilter="True" CurrentFilterFunction="Contains"
                                                    DataFormatString="{0:n}" ShowFilterIcon="False">
                                                    <HeaderStyle Width="200px" HorizontalAlign="Center" />
                                                    <ItemStyle HorizontalAlign="Left" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="Total" HeaderText="จำนวนสุทธิ" AllowFiltering="False"
                                                    UniqueName="Total" ShowFilterIcon="False" DataType="System.Decimal">
                                                    <%--DataFormatString="{0:n} บาท"--%>
                                                    <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                                    <ItemStyle HorizontalAlign="Right" />
                                                </telerik:GridBoundColumn>
                                            </Columns>
                                            <PagerStyle Mode="NumericPages" AlwaysVisible="true"
                                                FirstPageToolTip="กลับหน้าแรก" LastPageToolTip="ไปหน้าสุดท้าย"
                                                NextPagesToolTip="หน้าถัดไป" NextPageToolTip="หน้าถัดไป"
                                                PrevPagesToolTip="ย้อนกลับ" PrevPageToolTip="ย้อนกลับ" />
                                        </MasterTableView>
                                        <ClientSettings>
                                            <Selecting AllowRowSelect="true"></Selecting>
                                        </ClientSettings>
                                    </telerik:RadGrid>
                                </td>
                                <td>
                                    <table>
                                        <tr>
                                            <td>บัญชีกระแส :</td>
                                            <td>
                                                <telerik:RadComboBox ID="ddlBankAccSeq" runat="server" Filter="Contains"
                                                    DataTextField="bank_acc_name" DataValueField="bank_acc_seq"
                                                    AutoPostBack="true" Width="200px"
                                                    OnSelectedIndexChanged="ddlBankAccSeq_SelectedIndexChanged" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>เช็คเล่มที่/เลขที่ :</td>
                                            <td>
                                                <telerik:RadComboBox ID="ddlChequeSeq" runat="server" Width="200px" MaxHeight="200px" Filter="Contains"
                                                    DataTextField="cheque_name" DataValueField="cheque_seq" />
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td>
                                    <asp:Button ID="btnCollect" runat="server" Text="รวบรายการ" OnClick="btnCollect_Click" />
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                            </tr>
                            <tr>
                                <td style="font-size: medium; padding: 3px" class="auto-style1" colspan="3">
                                    <b>รวบรวมรายการที่ต้องออกเช็ค</b>
                                    <asp:Button ID="btnCheuqNew" runat="server" Text="รวมเช็คใหม่" OnClick="btnCheuqNew_Click" />
                                </td>

                            </tr>
                            <tr>
                                <td>
                                    <telerik:RadGrid ID="dgtPayrollCombine" runat="server" AllowRowSelect="true"
                                        AutoGenerateColumns="False" ShowStatusBar="True" AllowPaging="True" AllowSorting="True" Width="530px"
                                        CellSpacing="0" GridLines="None" Skin="Simple" PageSize="30"
                                        OnItemCommand="dgtPayrollCombine_ItemCommand">
                                        <MasterTableView AllowMultiColumnSorting="True" CellSpacing="-1" Width="100%"
                                            CommandItemDisplay="Top" CommandItemSettings-ShowRefreshButton="true" CommandItemSettings-ShowAddNewRecordButton="false"
                                            DataKeyNames="payroll_sentpayment_combine_seq" NoMasterRecordsText="< ไม่มีข้อมูล >">
                                            <Columns>
                                                <telerik:GridBoundColumn DataField="payroll_sentpayment_combine_name" HeaderText="รายการที่ต้องการออกเช็ค"
                                                    UniqueName="payroll_sentpayment_combine_name" AutoPostBackOnFilter="True" CurrentFilterFunction="Contains"
                                                    ShowFilterIcon="False">
                                                    <HeaderStyle Width="120px" HorizontalAlign="Center" />
                                                    <ItemStyle HorizontalAlign="Left" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="payroll_sentpayment_combine_seq" DataField="payroll_sentpayment_combine_seq" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="ConId" DataField="ConId" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="pay_seq" DataField="pay_seq" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="bgm_source_seq" DataField="bgm_source_seq" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="bgm_proj_oper_seq" DataField="bgm_proj_oper_seq" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="bgm_proj_oper_exp_seq" DataField="bgm_proj_oper_exp_seq" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="bgm_exp_grp_seq" DataField="bgm_exp_grp_seq" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="cheque_seq" DataField="cheque_seq" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="NameTh" HeaderText="จ่ายให้กับ"
                                                    UniqueName="NameTh" AutoPostBackOnFilter="True" CurrentFilterFunction="Contains"
                                                    DataFormatString="{0:n}" ShowFilterIcon="False">
                                                    <HeaderStyle Width="120px" HorizontalAlign="Center" />
                                                    <ItemStyle HorizontalAlign="Left" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="amount" HeaderText="จำนวนสุทธิ" AllowFiltering="False"
                                                    UniqueName="amount" ShowFilterIcon="False" DataType="System.Decimal">
                                                    <HeaderStyle Width="80px" HorizontalAlign="Center" />
                                                    <ItemStyle HorizontalAlign="Right" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="cheque_name" HeaderText="เลขที่เช็ค" AllowFiltering="False"
                                                    UniqueName="cheque_name" ShowFilterIcon="False">
                                                    <HeaderStyle Width="80px" HorizontalAlign="Center" />
                                                    <ItemStyle HorizontalAlign="Right" />
                                                </telerik:GridBoundColumn>
                                            </Columns>
                                            <PagerStyle Mode="NumericPages" AlwaysVisible="true"
                                                FirstPageToolTip="กลับหน้าแรก" LastPageToolTip="ไปหน้าสุดท้าย"
                                                NextPagesToolTip="หน้าถัดไป" NextPageToolTip="หน้าถัดไป"
                                                PrevPagesToolTip="ย้อนกลับ" PrevPageToolTip="ย้อนกลับ" />
                                        </MasterTableView>
                                    </telerik:RadGrid>
                                </td>
                                <td>
                                    <asp:Button runat="server" ID="btnSend" Enabled="true" Text="ส่งรายการไปที่การเงิน" OnClick="btnSentPayment_Click" />
                                    <br />
                                    <br />
                                    <b>
                                        <asp:Label ID="lblSubmitSucess" runat="server" Style="font-size: medium; color: green; padding: 3px" class="auto-style1"></asp:Label></b>
                                    <asp:Button runat="server" ID="btnPrint" Text="รายงานขออนุมัติจ่ายเงินเดือน" OnClientClick="openReqReport(); return false;" Visible="true" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </asp:Panel>
            </telerik:RadPageView>
        </telerik:RadMultiPage>
    </asp:Panel>

</asp:Content>
